﻿Namespace Hukuk

	Class Hatirlatma

		Shared Function Kaydet(ByVal Process As Token, ByVal sube As String, ByVal yil As Integer, ByVal sirano As Integer, ByVal isyerino As String, ByVal isyeriadi As String, ByVal adres As String, ByVal tarih As Date, ByVal ssy As String, ByVal sgy As String, ByVal imza1 As String, ByVal imza2 As String, ByVal kaykul As String) As Integer
			If sirano = 0 Then sirano = Process.OpenSQL("select isnull(max(sirano),0)+1 from hatirlatma where sube = :sube and yil = :yil", sube, yil)(0)
			Dim Rs As Recordset = Oku(Process, sube, yil, sirano)
			If Rs.EOF Then Rs.AddNew()
			Rs.SetValues("sube,yil,sirano,isyerino,isyeriadi,adres,tarih,ssy,sgy,imza1,imza2,kaykul", sube, yil, sirano, isyerino, isyeriadi, adres, tarih, ssy, sgy, imza1, imza2, kaykul)
			Rs.Save()
			Return sirano
		End Function

		Shared Function Oku(ByVal Process As Token, ByVal sube As String, ByVal yil As Integer, ByVal sirano As Integer) As Recordset
			Return Process.OpenSQL("select * from hatirlatma where sube = :sube and yil = :yil and sirano = :sirano", sube, yil, sirano)
		End Function

		Shared Function Liste(ByVal Process As Token, ByVal sube As String, ByVal isyerino As String, ByVal tarih1 As Date, ByVal tarih2 As Date) As Recordset
			Q("select * from hatirlatma where sube = " & sube)
			If Len(isyerino) = 6 Then Q("and isyerino = '" & isyerino & "'")
			If Not IsDBNull(tarih1) Then Q("and tarih >= '" & YMD(tarih1) & "'")
			If Not IsDBNull(tarih2) Then Q("and tarih <= '" & YMD(tarih2) & "'")
			Q("order by yil,sirano")
			Return Process.OpenSQL("*")
		End Function

	End Class

	Class Af2005

		Shared Function TaksitListesi(ByVal Token As Token, ByVal sno As Integer) As Recordset
			Return Token.OpenSQL("select * from taksit where sno = :sno order by yil,ay", sno)
		End Function

		Shared Sub Kaydet(ByVal Token As Token, ByVal List As Grid)
			Token.BeginTran()
			For i As Integer = 0 To List.RowCount - 1
				Dim Rs As Recordset = Token.OpenSQL("select * from taksit where rowid = @rowid", List.Cells(i, "rowid"))
				Rs.SetValues("yil,ay,borc,acik,makbuzno,tarih", List.Cells(i, "yil"), List.Cells(i, "ay"), List.Cells(i, "borc"), List.Cells(i, "acik"), List.Cells(i, "makbuzno"), List.Cells(i, "tarih"))
				Rs.Save()
			Next
			Token.CommitTran()
		End Sub

	End Class

	Class BorcuYoktur

		Shared Sub Kaydet(Token As Token, kod As String, isyerino As String, sure As String, bitistarihi As Date, sicilno As String, firmad As String, kaykul As String, yenisirket As Short)
			Dim Rs As Recordset = Token.OpenSQL("select * from Hukuk_CalismaIzni where 1 = 0")
			Rs.AddNew()
			Rs.SetValues("kod,isyerino,verilensure,verilentarih", kod, isyerino, sure, Token.SysDate)
			Rs.SetValues("bitistarih,sicilno,sirketadi,pcname,yenisirket", bitistarihi, sicilno, firmad, kaykul, yenisirket)
			Rs.Save()
		End Sub

		Shared Function SiraNo(Token As Token) As String
			Return Token.OpenSQL("select isnull(max(Kod),0)+1 from Hukuk_CalismaIzni")(0)
		End Function

		Shared Function Oku(Token As Token, isyerino As String) As Recordset
			Return Token.OpenSQL("select * from Hukuk_CalismaIzni where isyerino = @isyerino order by BitisTarih desc, VerilenTarih desc", isyerino)
		End Function

		Shared Function Liste(Token As Token, belgesecimi As Integer, isyerino As String, sure As Integer) As Recordset
			Q("select Kod ,isyeriNo,VerilenSure,VerilenTarih, BitisTarih, SicilNo, ltrim(SirketAdi) as SirketAdi, PcName ,YeniSirket from Hukuk_CalismaIzni  where 1=1")
			If belgesecimi <> 0 Then Q("and year(VerilenTarih) = " & belgesecimi)
			If Not isyerino = "" Then Q("and isyerino = '" & isyerino & "'")
			If sure <> 0 Then Q("and VerilenSure = " & sure)
			Q("order by VerilenTarih,Kod ")
			Return Token.OpenSQL("*")
		End Function

	End Class

End Namespace
